﻿@{
    Layout = "_Layout";
}
@using Nxg.Blog.Core.Documents
@using Nxg.Blog.Core.Extensions
@model Nxg.Blog.Core.ViewProjections.Admin.AllBlogPostsViewModel
<div class="main">
    <div class="post-wrap archive">
        <table class="table" style="width: 100%;">
            <thead>
                <tr>
                    <th style="width: 50%;text-align:left;">Title</th>
                    <th style="width: 10%;text-align:left">ViewCount</th>
                    <th style="width: 20%;text-align:left">CreateTime</th>
                    <th style="width: 20%;text-align:left;width:46px;" class="text-center" >Operation</th>
                </tr>
            </thead>
            <tbody>
                @foreach (var blogPost in Model.Posts)
                {
                    <tr>
                        <td>
                            <a href="@blogPost.GetLink()">@blogPost.Title</a>
                            @if (blogPost.Status == PublishStatus.Draft)
                            {
                                <span class="label label-warning">draft</span>
                            }
                            else if (blogPost.PubDate > DateTime.Now)
                            {
                                <span class="label label-info">prelease </span>
                            }
                        </td>
                        <td>
                            @blogPost.ViewCount
                        </td>
                        <td>
                            @blogPost.PubDate.ToString("yyyy-MM-dd hh:mm")
                        </td>
                        <td>
                            <a href="~/Post/Edit/@blogPost.Id" class="btn btn-default btn-xs">编辑</a>
                            <a href="~/Post/Delete/@blogPost.Id" class="btn btn-danger btn-xs">删除</a>
                        </td>
                    </tr>
                }
            </tbody>
        </table>

        <div style="text-align:center;">
            @if(Model.HasPrevPage){
                <a href="/post/@(Model.Page-1)">pre</a>
            }

            @if(Model.HasNextPage && Model.HasPrevPage){
                <span>.</span>
            }
            
            @if(Model.HasNextPage){
                <a href="/post/@(Model.Page+1)">next</a>
            }
        </div>
    </div>
</div>